<template>
  <div id="app">
    <router-view @loginSuccess="handleLoginSuccess"></router-view>
  </div>
</template>

<script>
export default {
  methods: {
    handleLoginSuccess({ account, role, name }) {
      console.log('handleLoginSuccess:', account, role, name);

      const roleRouteMap = {
        admin: '/admin/Main',
        employee: '/employee/Main2',
        user: '/user/Main3'
      };

      const routePath = roleRouteMap[role];
      if (routePath) {
        this.$router.push({
          path: routePath,
          query: {
            account: account,
            role: role,
            name: name,
          }
        });
      } else {
        console.error('Unknown role:', role);
      }
    }
  }
};
</script>

<style>
#app {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
}
</style>
